export const GET_NEWSONGS = "GET_NEWSONGS";
export const GET_NEWSONGS_SUCCESS = "GET_NEWSONGS_SUCCESS";
export const GET_NEWSONGS_FAILED = "GET_NEWSONGS_FAILED";

export interface IGetNewSongsAction {
  type: typeof GET_NEWSONGS;
}

export interface INewSong {
  alg: string;
  canDislike: boolean;
  copywriter: null | object;
  id: number;
  name: string;
  picUrl: string;
  trackNumberUpdateTime: null | number;
  type: number;
  song: any;
}

export interface INewSongsListData {
  category: number;
  code: number;
  result: INewSong[];
}

export interface IGetNewSongsSuccessAction {
  type: typeof GET_NEWSONGS_SUCCESS;
  payload: INewSongsListData;
}

export interface IGetNewSongsFailedAction {
  type: typeof GET_NEWSONGS_FAILED;
  payload: string;
}

export const getNewSongs = (): IGetNewSongsAction => {
  return {
    type: GET_NEWSONGS,
  };
};

export const getNewSongsSuccess = (
  payload: INewSongsListData
): IGetNewSongsSuccessAction => {
  return {
    type: GET_NEWSONGS_SUCCESS,
    payload,
  };
};

export const getNewSongsFailed = (
  payload: string
): IGetNewSongsFailedAction => {
  return {
    type: GET_NEWSONGS_FAILED,
    payload,
  };
};

export type NewSongsUnionActionType =
  | IGetNewSongsAction
  | IGetNewSongsFailedAction
  | IGetNewSongsSuccessAction;
